
package com.joysuch.wwyt.core.service;

import com.joysuch.wwyt.api.base.vo.ApiConfigVo;
import com.joysuch.wwyt.api.mh.dto.TenantBean;
import com.joysuch.wwyt.core.bean.AddConfigBean;
import com.joysuch.wwyt.core.bean.BaseConfigBean;
import com.joysuch.wwyt.core.bean.BaseConfigTypeBean;
import com.joysuch.wwyt.core.entity.BaseConfig;
import com.joysuch.wwyt.core.entity.BaseConfigType;
import com.joysuch.wwyt.dzhapi.dto.BuildDataDto;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import static com.joysuch.wwyt.core.bean.BaseConfigBean.SearchBaseConfig;

public interface BaseConfigService {

    /**
     * 不允许编辑的参数code
     *
     * key：配置编码，value：错误提示
     */
    Map<String, String> EDIT_NOT_ALLOWED_CODE_MAP = new HashMap<String, String>() {
        {
            put("websocketBuildId", "建筑ID不允许修改！");
        }
    };

    /**
     * 找出url和token不为空的配置的tenentId和orgCode
     * @param url
     * @param token
     * @return
     */
    List<Map<String,Object>> selectTenentIdAndOrgCodes(String url , String token);
    
    BaseConfig findConfig(Long tenentId, String companyCode, String code);

    BaseConfig findConfig(String code);

    BaseConfig add(AddConfigBean bean);

    BaseConfig addConfig(String key, String value);

    BaseConfig addConfig(String key, String value, Long tenentId, String companyCode);

    /**
     * 根据编码和租户公司更新配置值
     * @param config
     * @param value
     */
    BaseConfig updateConfigValue(BaseConfig config, String value);

    void updateConfig(BaseConfig bean);

    void delete(Long id);

    Page<BaseConfigBean> findByPage(Pageable page, SearchBaseConfig condition);

    List<BaseConfig> findConfigList(Long tenentId, String companyCode);

    BaseConfigType saveType(BaseConfigTypeBean bean);

    BaseConfigTypeBean findTypeById(Long id);

    List<BaseConfigTypeBean> getTypeList();

    void deleteTypeById(Long id);

    BaseConfig findFirstConfig(String code);

    boolean checkIfSync(Long tenentId, String orgCode);

    boolean checkIfSync();

    boolean checkApiIfSync(BuildDataDto dto);

    List<ApiConfigVo> findByTypeId(Long typeId);

    BaseConfig findByTenentIdAndOrgCodeAndCode2(Long tenentId, String orgCode, String zd_processDefKeyNew);

    List<BaseConfig> findConfigByList(List<TenantBean> tenantBeans, String monitorPointHttpServerUrl);

    BaseConfig getBaseConfigFromRedis(String code);
}
